;;;
;;;	Author: Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;	http://www.paracadd.com
;;;	All rights reserved.
;;;
;;;	Copyright:	11-25-2013
;;;	   Edited:	11-25-2013
;;;
;;;	Requires:	Irfanview - http://www.irfanview.com/
;;;			DOSLIB	  - http://www.en.na.mcneel.com/doslib.htm
;;;			check_for_doslib.lsp - assures DOSLIB is loaded if available
;;;			have_irfanview.lsp - checks irfanview availability
;;;
;;;	Modifies typical screen capture images of area maps so that they will
;;;	print well from within AutoCAD.  Program adjusts brightness and gamma
;;;	settings and converts the image to grayscale, then it adjusts contrast
;;;	and gamma before saving the final result.  The resolution captured is
;;;	not changed.
;;;
(defun C:VMap ()
  (if check_for_doslib NIL (LOAD "check_for_doslib" "\nFile CHECK_FOR_DOSLIB.LSP was not loaded! "));assures DOSLIB is loaded if it is available
  (IF have_irfanview
    nil
    (LOAD "have_irfanview"
          "\nFile HAVE_IRFANVIEW.LSP not loaded! "
    ) ;_ end of LOAD
  ) ;_ end of IF
  (IF (AND (have_irfanview) 'dos_about)
    (PROGN
      (setq this-map (dos_getfiled "Select Map Image to modify" (GETVAR "dwgprefix") "GIF Images|*.gif|JPG Images|*.jpg|BMP Images|*.bmp|All Files|*.*||"))
      (setq split-this-map (dos_splitpath this-map))
      (if (and this-map split-this-map)
        (progn
          (if ukword NIL (load "ukword" "\nFile UKWORD.LSP not loaded! "))
          (setq map-type (ukword 1 "Vicinity Location Area" "New image name [Vicinity/Location/Area]" (if map-type map-type "Vicinity")))
          (setq map-prefix (ukword 1 "Yes No" "Add project number prefix to name [Yes/No]" (if map-prefix map-prefix "Yes")))
          (if (eq map-prefix "Yes")
            (PROGN
              (setq cnt 1)
              (setq name-prefix (SUBSTR (NTH 1 split-this-map)2))
              (while (and
                       (wcmatch name-prefix "* *")
                       (not (wcmatch (substr name-prefix 1 cnt) "* "))
                     )
                (setq cnt (1+ cnt))
              )
              (if (eq cnt 1)
                NIL
                (setq name-prefix (substr name-prefix 1 (1- cnt)))
              )
              (cond
                ((wcmatch name-prefix "????-##`.##")
                  (setq name-prefix (strcat (substr name-prefix 1 4)(substr name-prefix 6 2)(substr name-prefix 9 2))))
                ((wcmatch name-prefix "?????-##`.##")
                  (setq name-prefix (strcat (substr name-prefix 1 5)(substr name-prefix 7 2)(substr name-prefix 10 2))))
              )
            )
          )
          (if (and name-prefix (/= name-prefix "") (eq map-prefix "Yes"))
            (setq new-map-name (subst (strcat name-prefix "-" map-type "Map")(nth 2 split-this-map) split-this-map))
            (setq new-map-name (subst (strcat map-type "Map")(nth 2 split-this-map) split-this-map))
          )
          (setq new-map-name (eval (cons 'strcat (subst ".gif" (nth 3 new-map-name) new-map-name))))
          (DOS_EXEWAIT
            (STRCAT
              "\""
              (FINDFILE found_iv)
              "\" \""
              this-map
              "\" /bright=245 /gamma=0.03 /gray /killmesoftly /convert=\""
              new-map-name
              "\""
            ) ;_ end of STRCAT
          ) ;_ end of DOS_EXEWAIT
          (DOS_EXEWAIT
            (STRCAT
              "\""
              (FINDFILE found_iv)
              "\" \""
              new-map-name
              "\" /contrast=80 /gamma=0.2 /gray /killmesoftly /convert=\""
              new-map-name
              "\""
            ) ;_ end of STRCAT
          ) ;_ end of DOS_EXEWAIT
        )
      )
    )
    (Alert "Either IrfanView or Doslib are not available")
  )
  (PRINC)
)
(DEFUN C:VICINITYMAP () (c:vmap))
(DEFUN C:LOCATIONMAP () (c:vmap))
(DEFUN C:AREAMAP () (c:vmap))
